package com.cys.dm.rabbitService;

import com.cys.dm.client.order.DmOrderLinkUserClient;
import com.cys.dm.entity.order.DmOrderLinkUser;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author blue_t
 * @date 2020-12-27 15:49
 */
@RabbitListener(queues = {"dm-order-link-user-back"})
@Component
public class DmOrderLinkUserBack {
    @Autowired
    private DmOrderLinkUserClient dmOrderLinkUserClient;


    /**
     * 回滚订单联系人
     * @param linkUsers 订单联系人集合
     */
    @RabbitHandler
    public void orderLinkUserRollback(List<DmOrderLinkUser> linkUsers){
        linkUsers.forEach(x->{
            dmOrderLinkUserClient.deleteOrderLinkUser(x);
        });
        System.out.println("订单联系人回滚了-------------");
    }
}
